<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
    <head>
        <title>Title</title>

        <script src="${pageContext.request.contextPath}/js/jquery-3.3.1.min.js"></script>

        <script>

            $(function(){

                $("a").click(function(){
                    $("#image").prop("src","${pageContext.request.contextPath}/code/getCodeImage?a="+new Date().getTime());
                });


                $("#code").blur(function(){

                    $.ajax({
                        url:"${pageContext.request.contextPath}/code/validateCode",
                        data:{"code":$(this).val()},
                        success:function(message){
                            $("#codeMessage").text(message);
                        }
                    });

                });
            });

        </script>

    </head>
    <body>


        <a href="javascript:"><img id="image" src="${pageContext.request.contextPath}/code/getCodeImage"/></a>
        <a href="javascript:">换一张</a>
        <input id="code" type="text" name="code" size="5"/><br/>
        <span id="codeMessage"></span>

    </body>
</html>
